home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 19 / Amiga Plus Leser CD 19.iso / Tools / Freeware / ttengine-5.0 / Developer / autodocs / ttengine.doc
Encoding:
Text File  |  2002-11-13  |  31.3 KB  |  837 lines

  1. TABLE OF CONTENTS
  2.  
  3. ttengine.library/background
  4. ttengine.library/font_database
  5. ttengine.library/TT_CloseFont
  6. ttengine.library/TT_DoneRastPort
  7. ttengine.library/TT_FreePixmap
  8. ttengine.library/TT_GetAttrsA
  9. ttengine.library/TT_GetPixmapA
  10. ttengine.library/TT_OpenFontA
  11. ttengine.library/TT_SetAttrsA
  12. ttengine.library/TT_SetFont
  13. ttengine.library/TT_Text
  14. ttengine.library/TT_TextExtent
  15. ttengine.library/TT_TextFit
  16. ttengine.library/TT_TextLength
  17. ttengine.library/background                       ttengine.library/background
  18.  
  19.  
  20.    PURPOSE
  21.  
  22.    The library is fast, AmigaOS friendly TrueType render engine. It has
  23.    nothing to do with Amiga outline font system. This system has a lot of
  24.    limitations which make it useless for high speed and quality text output.
  25.    If someone wants an integration of TrueType with AmigaOS bullet.library
  26.    like outline font system, should consider using ttf.library. This library
  27.    opens TrueType font by itself and renders high quality glyphs directly
  28.    into any RastPort.
  29.  
  30.    FREETYPE2 BASED
  31.  
  32.    The render engine of the library is based on FreeType2 project
  33.    (http://www.freetype.org). This version of ttengine.library uses 2.0.9
  34.    FreeType build.
  35.  
  36.    REQUIREMENTS
  37.  
  38.    - OS 3.0+.
  39.    - 68020 or better processor.
  40.    - for antialiased output graphics board with at least 15-bit screenmode
  41.      and RTG system: CyberGraphX 3.x+ or Picasso96 2.x+.
  42.  
  43.    FEATURES
  44.  
  45.    The library expands FreeType functionality making usage of TrueType fonts
  46.    easy and comfortable. Below you can find key features:
  47.  
  48.    - renders whole strings (not single glyphs) with kerning.
  49.    - antialiasing to any (not neccesarily uniform color) background.
  50.    - system compatible output to any (including planar) RastPort.
  51.    - supports JAM1. JAM2, INVERSVID, COMPLEMENT RastPort modes.
  52.    - supports 8-bit to Unicode mapping with "ENV:ttfcodepage" table
  53.      compatible with ttf.library.
  54.    - allows for direct 16-bit Unicode string rendering.
  55.    - easy to use, taglist based API almost identical to graphics.library
  56.      font API.
  57.    - efficient system-wide glyph cache system.
  58.  
  59.    CACHE SYSTEM
  60.  
  61.    The library uses my own (not that experimental FreeType one) cache system
  62.    speeding up strings rendering alot. The cache is system-wide, it means it
  63.    is common to every application using ttengine.library. Only used glyphs of
  64.    given font face are cached. If the library encounters cache miss, missing
  65.    glyph is loaded and rasterized on the fly. Cache system is totally
  66.    transparent to the library user, so there are no cache functions in the
  67.    library API. Cache uses one single Exec memory pool avoiding memory
  68.    fragmentation.
  69.  
  70. ttengine.library/font_database                 ttengine.library/font_database
  71.  
  72.    GENERAL INFORMATION
  73.  
  74.    'ttengine.database' is a plain text file (placed in 'ENV:' directory)
  75.    containing informations about TrueType fonts available in the system.
  76.    There is no tool (yet) to automatically generate it, the database have to
  77.    be written by hand. Every line contains one keyword followed by parameter
  78.    value. Name and value can be separated by space(s) or equality sign,
  79.    exactly the same as shell command parameters (to say more - database is
  80.    parsed by the same ReadArgs() system call as shell command parameters
  81.    are). Parameter values containing spaces should be quoted. Here are some
  82.    examples:
  83.  
  84.    FAMILY Tahoma
  85.    FAMILY=Times
  86.    FAMILY = "Times New Roman"
  87.    FAMILY "Weird Font"
  88.  
  89.    KEYWORDS
  90.  
  91.    FAMILY - defines the name used for font opening. All variants of the font
  92.    (italic, bold, black, heavy, light, demi etc.) will have the same family
  93.    name. Family names (and aliases described below) are case insensitive.
  94.  
  95.    ALIAS - defines another name for the same family. It generally has three
  96.    purposes:
  97.  
  98.    1. Similar names for the same font, like "Times", "TimesNewRoman" and
  99.    "Times New Roman".
  100.  
  101.    2. One replacement font for some very similar ones, for example
  102.    "Helvetica" and "Switzerland" can be aliased to "Arial".
  103.  
  104.    3. Generic names like "default", "serif", "sans-serif", "monospaced". An
  105.    application can request generic name without specific family name, or
  106.    generic font can be used as a fallback if given name can't be found in
  107.    the database. For example you can alias "monospaced" to "Courier", and an
  108.    application (be it CSS compatible HTML viewer) can request
  109.    'LucidaConsole, monospaced'. If there is no LucidaConsole font in the
  110.    system, Courier will be used. The same way you can alias any font to any
  111.    other, for example Times to Arial, this makes not much sense however.
  112.    'default' font can be used as a last resort.
  113.  
  114.    FILE - defines single TrueType font file and its attributes, which are:
  115.      FILE itself - defines a path to the font file. Font files can be placed
  116.        anywhere in the filesystem(s). There is no default value for the
  117.        attribute, it must be given explicitly.
  118.      WEIGHT - defines font weight in Cascading Style Sheets manner, where 0
  119.        means the lightest and 999 means the heaviest weight. 400 is typical
  120.        value for normal weight, 700 for bold. Default value is 400 (normal).
  121.      STYLE - "regular" or "italic" for italic and oblique faces. Default
  122.        value is "regular".
  123.      SMOOTHSMALL - controls antialiasing of small sizes. Any sizes smaller or
  124.        equal to SMOOTHSMALL will be antialiased. Note: can be overriden by
  125.        application. Default value is 9.
  126.      SMOOTHBIG - controls antialiasing of big sizes. Any sizes bigger or
  127.        equal to SMOOTHBIG will be antialiased. Note: can be overriden by
  128.        application. Default value is 18.
  129.  
  130.      Every FILE is automatically added to the nearest FAMILY defined above
  131.      in the database file. Every ALIAS or FILE placed before the first
  132.      FAMILY is rejected quietly.
  133.  
  134.    COMMENTS
  135.  
  136.    You can place any full-line comments in the file starting a line with
  137.    hash or semicolon. End-line comments are not supported.
  138.  
  139. ttengine.library/TT_CloseFont                   ttengine.library/TT_CloseFont
  140.  
  141.    NAME
  142.        TT_CloseFont -- Closes TrueType font. (V4)
  143.  
  144.    SYNOPSIS
  145.        TT_CloseFont (font)
  146.                      A0
  147.  
  148.        VOID TT_CloseFont (APTR);
  149.  
  150.    FUNCTION
  151.        Closes font opened by TT_OpenFontA()
  152.  
  153.    INPUTS
  154.        font - the result of TT_OpenFontA(). Can be NULL, no action is taken
  155.            in the case.
  156.  
  157.    RESULT
  158.        none
  159.  
  160.    NOTES
  161.  
  162.    BUGS
  163.  
  164.    SEE ALSO
  165.        TT_OpenFontA()
  166.  
  167. ttengine.library/TT_DoneRastPort             ttengine.library/TT_DoneRastPort
  168.  
  169.    NAME
  170.        TT_DoneRastPort -- Releases TTEngine resources associated to a
  171.          RastPort. (V5)
  172.  
  173.    SYNOPSIS
  174.        TT_DoneRastPort (rastport)
  175.                         A1
  176.  
  177.        VOID TT_DoneRastPort (struct RastPort*);
  178.  
  179.    FUNCTION
  180.        Frees internal TTEngine resources associated with a RastPort.
  181.        TTEngine creates rendering environment for every RastPort at first
  182.        call of TT_SetFont() or TT_SetAttrs() for this RastPort. You should
  183.        free this environment before disposing RastPort (typically before
  184.        closing a window or screen). Leaving rendering environment not freed
  185.        has two drawbacks. Firstly it causes memory leak, this memory is
  186.        recovered however when ttengine.library is expunged. Secondly it is
  187.        possible that a new RastPort will be created at the same address as
  188.        disposed one. Then TTEngine will not create new rendering context but
  189.        use old instead, which can lead to some unexpected behaviour.
  190.  
  191.    INPUTS
  192.        rastport - pointer to RastPort. Rendering environment for this
  193.          RastPort will be disposed. Can be NULL, in the case function does
  194.          nothing.
  195.  
  196.    RESULT
  197.        none
  198.  
  199.    EXAMPLE
  200.        font = TT_OpenFont( /* tags */ );
  201.        window = OpenWindowTags(NULL, /* tags */);
  202.        TT_SetFont(rport, font);   /* environment is created here */
  203.        TT_SetAttrs(rport, TT_Window, window, /* ... */);
  204.  
  205.        /* you can call TT_SetAttrs() and TT_SetFont() as many times */
  206.        /* as you want */
  207.  
  208.        TT_DoneRastPort(rport);   /* environment is disposed */
  209.        CloseWindow(window);      /* RastPort is disposed */
  210.  
  211.    NOTES
  212.  
  213.    BUGS
  214.  
  215.    SEE ALSO
  216.        TT_SetAttrsA(), TT_SetFont()
  217.  
  218. ttengine.library/TT_FreePixmap                 ttengine.library/TT_FreePixmap
  219.  
  220.    NAME
  221.        TT_FreePixmap -- Releases grayscale pixmap. (V5)
  222.  
  223.    SYNOPSIS
  224.        TT_FreePixmap (pixmap)
  225.                       A0
  226.  
  227.        VOID TT_FreePixmap (struct TT_Pixmap*);
  228.  
  229.    FUNCTION
  230.        Frees pixmap data and structure allocated by TT_GetPixmap().
  231.  
  232.    INPUTS
  233.        pixmap - pointer to TT_Pixmap structure. May be NULL, function does
  234.          nothing in the case.
  235.  
  236.    RESULT
  237.        none
  238.  
  239.    NOTES
  240.  
  241.    BUGS
  242.  
  243.    SEE ALSO
  244.        TT_GetPixmapA()
  245.  
  246. ttengine.library/TT_GetAttrsA                   ttengine.library/TT_GetAttrsA
  247.  
  248.    NAME
  249.        TT_GetAttrsA -- Gets current font and render engine attributes (V4).
  250.  
  251.    SYNOPSIS
  252.        count = TT_GetAttrsA (rastport, taglist)
  253.                              A1        A0
  254.  
  255.        ULONG TT_GetAttrsA (struct RastPort*, struct TagItem*);
  256.  
  257.        count = TT_GetAttrs (rastport, Tag1, ...)
  258.  
  259.        ULONG TT_GetAttrs (struct RastPort*, Tag, ...);
  260.  
  261.    FUNCTION
  262.        Gets current font or render engine attributes for given RastPort. The
  263.        value of every attribute is written to an ULONG pointed by ti_Data
  264.        field of the TagItem. Here is a list of attributes:
  265.  
  266.        TT_Antialias - Current state of an antialias switch (on, off or
  267.           auto).
  268.  
  269.        TT_FontAscender - This is a distance (in pixels) between the baseline
  270.          and top elements of the font (typically these elements are accents
  271.          of capital letters). NOTE: many shareware TT fonts have wrong ascen-
  272.          der value.
  273.  
  274.        TT_FontDescender - This is a distance (in pixels) between the
  275.          baseline and bottom elements of the font (typically in letters 'p',
  276.          'q', 'g' etc.). NOTE: many shareware TT fonts have wrong descender
  277.          value. Descender value is typically negative (as bottom elements
  278.          usually are placed below the baseline).
  279.  
  280.        TT_FontName - full font name as found in the font file. Pointer to a
  281.          NULL-terminated string is written. This string is localized if the
  282.          font file contains names in different languages. Language
  283.          precedence is loaded from "Preferred languages" table of
  284.          locale.library.
  285.  
  286.        TT_FamilyName - font family name as found in the font file. Pointer
  287.          to a NULL-terminated string is written. This string is localized if
  288.          the font file contains names in different languages. Language
  289.          precedence is loaded from "Preferred languages" table of
  290.          locale.library.
  291.  
  292.        TT_SubfamilyName - font subfamily name (typically describing font
  293.          variant like "italic" or "bold") as found in the font file. Pointer
  294.          to a NULL-terminated string is written. This string is localized if
  295.          the font file contains names in different languages. Language
  296.          precedence is loaded from "Preferred languages" table of
  297.          locale.library.
  298.  
  299.        TT_Transparency - returns actual transparency setting.
  300.  
  301.        NOTE: TTFA_Ascender and TTFA_Descender are guarranted to fulfill
  302.        following formula: ascender - descender = font height.
  303.  
  304.    INPUTS
  305.        rastport - attributes associated with this RastPort will be returned.
  306.        taglist - the list of attributes.
  307.  
  308.    RESULT
  309.        counter - the count of recognized tags.
  310.  
  311.    NOTES
  312.        Data returned are valid only until TT_CloseFont() call.
  313.  
  314.    BUGS
  315.  
  316.    SEE ALSO
  317.        TT_OpenFontA(), TT_SetAttrsA()
  318.  
  319. ttengine.library/TT_GetPixmapA                 ttengine.library/TT_GetPixmapA
  320.  
  321.    NAME
  322.        TT_GetPixmapA -- Renders string to 8-bit grayscale pixel map. (V5)
  323.  
  324.    SYNOPSIS
  325.        pixmap = TT_GetPixmapA (font, string, count, taglist)
  326.                                    A1    A2      D0     A0
  327.  
  328.        struct TT_Pixmap *TT_GetPixmapA (APTR, APTR, ULONG, struct TagItem*);
  329.  
  330.        pixmap = TT_GetPixmap (font, string, count, Tag1, ...)
  331.  
  332.        ULONG TT_GetPixmap (APTR, APTR, ULONG, Tag, ...);
  333.  
  334.    FUNCTION
  335.        Renders a string to 8-bit grayscale pixel map. Function may be useful
  336.        if the string image is additionally manipulated before rendering into
  337.        RastPort (e.g. in image processing software). Pixel map is a
  338.        continuous memory area where one byte represents one gray pixel (0 is
  339.        black, 255 is white). The first byte is the upper left pixmap corner.
  340.        Pixels are placed left-to-right in rows, rows are placed
  341.        top-to-bottom. There is no row padding, it means pixmap modulo is
  342.        always the same as pixmap width and pixmap data size is equal to width
  343.        * height. The function accepts following tags:
  344.  
  345.        TT_Antialias - (BOOL) - controls antialiasing (on, off or
  346.          automatic):
  347.          TT_Antialias_Off - turns antialias off
  348.          TT_Antialias_On - turns antialias on
  349.          TT_Antialias_Auto (default) - antialias state depends on font
  350.            size. Typically sizes of 9 or less pixels are antialiased, sizes
  351.            from 10 to 19 pixels are not antialiased, sizes of 20 of more
  352.            pixels are antialiased. These settings can be changed in the font
  353.            database separately for every font face.
  354.  
  355.        TT_Encoding - selects font encoding table to be used:
  356.          TT_Encoding_Default - loads encoding table from "ENV:ttfcodepage"
  357.            file, compatible with ttf.library. If no such file is found,
  358.            ISO-8859-1 encoding (Amiga default) is used.
  359.          TT_Encoding_Unicode - strings are interpreted as tables of 16-bit
  360.            Unicode characters.
  361.          TT_Encoding_WideUnicode - strings are interpreted as tables of
  362.            32-bit Unicode characters.
  363.          TT_Encoding_ISO8859_1 - ISO-8859-1 (Western Europe).
  364.          TT_Encoding_ISO8859_2 - ISO-8859-2 (Eastern and Central Europe).
  365.  
  366.        TT_ScaleX - a floating point (IEEE single precision) horizontal scale
  367.          factor. Its absolute value will be limited to <0.01, 100> range. It
  368.          may be negative (it means horizontal mirror around starting pen
  369.          position, string will be rendered to the left).
  370.  
  371.        TT_ScaleY - a floating point (IEEE single precision) vertical scale
  372.          factor. Its absolute value will be limited to <0.01, 100> range. It
  373.          may be negative (it means vertical mirror around the baseline,
  374.          string will be rendered mostly under the baseline).
  375.  
  376.    INPUTS
  377.        font - font pointer obtained with TT_OpenFont().
  378.        string - pointer to string to be rendered to a pixmap.
  379.        count - length of the string in characters (only equal to bytes in
  380.          pure 8-bit encodings).
  381.        taglist - list of rendering attributes.
  382.  
  383.    RESULT
  384.        pixmap - structure describing a pixmap defined as follows:
  385.  
  386.        struct TT_Pixmap
  387.          {
  388.            ULONG  ttp_Size;
  389.            ULONG  ttp_Width;
  390.            ULONG  ttp_Height;
  391.            UBYTE *ttp_Data;
  392.          };
  393.  
  394.        ttp_Size is the size of the structure (not the pixmap) containing
  395.        useful informations including ttp_Size itself. For V5 pixmaps the size
  396.        is 16 bytes. ttp_Width is pixmap width (and modulo) in bytes.
  397.        ttp_Height is a number of pixmap rows. ttp_Data points to actual
  398.        pixmap data.
  399.  
  400.        Function returns NULL if pixmap allocation fails.
  401.  
  402.    NOTES
  403.        TT_Pixmap structure is READ ONLY.
  404.  
  405.    BUGS
  406.  
  407.    SEE ALSO
  408.        TT_FreePixmap(), TT_OpenFontA(), TT_SetAtrrsA()
  409.  
  410. ttengine.library/TT_OpenFontA                   ttengine.library/TT_OpenFontA
  411.  
  412.    NAME
  413.        TT_OpenFontA -- Opens TrueType font. (V4)
  414.  
  415.    SYNOPSIS
  416.        font = TT_OpenFontA (taglist)
  417.                                A0
  418.  
  419.        APTR TT_OpenFontA (struct TagItem*);
  420.  
  421.        font = TT_OpenFont (Tag1, ...)
  422.  
  423.        APTR TT_OpenFont (Tag, ...);
  424.  
  425.    FUNCTION
  426.        Opens a TrueType font preparing it to use with any RastPort. Font may
  427.        be specified directly as a path to "*.ttf" file, or indirectly via
  428.        set of attributes, database search will be performed for this set and
  429.        best matching font will be opened. It is graphics.library OpenFont()
  430.        counterpart but taglist is used instead TextAttr structure.
  431.  
  432.    INPUTS
  433.        taglist - a list of tags containing requested font attributes.
  434.               Following tags are recognized:
  435.          TT_FontFile - this tag is a pointer to string containing a full
  436.               path to TrueType font file to be opened. This tag allows for
  437.               overriding database search and match. That means
  438.               TT_FamilyTable, TT_FontStyle and TT_FontWeight are ignored if
  439.               TT_FontFile is specified. Useful for opening application
  440.               specific fonts, containing for example musical notes or some
  441.               other kind of symbols. This tag has no default value.
  442.          TT_FamilyTable - NULL-terminated table of pointers to font family
  443.               names from the most desired to the last resort fallback. It is
  444.               intended for easy implementing things like HTML 'FONT FACE'
  445.               attribute. You can use real family names here, as well as
  446.               generic names: 'serif', 'sans-serif', 'monospaced', 'cursive',
  447.               'fantasy', and 'default', especially useful as a fallbacks.
  448.               Family names are case insensitive.
  449.               The default value for the tag is {"default", NULL};
  450.          TT_FontSize - font size in pixels defined as the distance between
  451.               baselines of two following text lines. The default value for
  452.               this tag is 14 pixels.
  453.          TT_FontStyle - there are three styles defined:
  454.               TT_FontStyle_Regular (default),
  455.               TT_FontStyle_Italic,
  456.          TT_FontWeight - defined with Cascading Style Sheets manner as a
  457.               number from 0 (the lightest face) to 999 (the heaviest face).
  458.               You can use TT_FontWeight_Normal (equal to 400) and
  459.               TT_FontWeight_Bold (equal to 700) shortcuts.
  460.               TT_FontWeight_Normal is the default value.
  461.  
  462.    RESULT
  463.        success - font pointer (for use with TT_SetFont() and TT_CloseFont())
  464.                  if the font has been opened successfully, NULL
  465.                  otherwise. This function can fail for four reasons:
  466.                  1. There is no matching face in the database (NOTE: even
  467.                     'default' can fail if not defined in the database!)
  468.                  2. File not found or malformed.
  469.                  3. Zero font size.
  470.                  4. No memory for requested (too big?) size.
  471.  
  472.    NOTES
  473.  
  474.    BUGS
  475.  
  476.    SEE ALSO
  477.        TT_SetFont(), TT_CloseFont(), font_database
  478.  
  479. ttengine.library/TT_SetAttrsA                   ttengine.library/TT_SetAttrsA
  480.  
  481.    NAME
  482.        TT_SetAttrsA -- Sets rendering engine and font attributes. (V4)
  483.  
  484.    SYNOPSIS
  485.        count = TT_SetAttrsA (rastport, taglist)
  486.                              A1        A0
  487.  
  488.        ULONG TT_SetAttrsA (struct RastPort*, struct TagItem*);
  489.  
  490.        count = TT_SetAttrs (rastport, Tag1, ...)
  491.  
  492.        ULONG TT_SetAttrs (struct RastPort*, Tag, ...);
  493.  
  494.    FUNCTION
  495.        Sets render engine settings for given RastPort. Every following
  496.        TrutType render and metrics calls for this RastPort will use these
  497.        settings. Here is a list of attributes:
  498.  
  499.        TT_ColorMap - (struct ColorMap*) - ColorMap used to convert pen
  500.          number to RGB color value.
  501.  
  502.        TT_Screen - (struct Screen*) - useful shortcut for TT_ColorMap,
  503.          automatically sets screen ColorMap.
  504.  
  505.        TT_Window - (struct Window*) - useful shortcut for TT_ColorMap,
  506.          automatically sets window ColorMap.
  507.  
  508.        TT_Antialias - (BOOL) - controls antialiasing (on, off or
  509.          automatic):
  510.          TT_Antialias_Off - turns antialias off
  511.          TT_Antialias_On - turns antialias on
  512.          TT_Antialias_Auto (default) - antialias state depends on font
  513.            size. Typically sizes of 9 or less pixels are antialiased, sizes
  514.            from 10 to 19 pixels are not antialiased, sizes of 20 of more
  515.            pixels are antialiased. These settings can be changed in the font
  516.            database separately for every font face.
  517.  
  518.        TT_Encoding - selects font encoding table to be used:
  519.          TT_Encoding_Default - loads encoding table from "ENV:ttfcodepage"
  520.            file, compatible with ttf.library. If no such file is found,
  521.            ISO-8859-1 encoding (Amiga default) is used.
  522.          TT_Encoding_Unicode - strings are interpreted as tables of 16-bit
  523.            Unicode characters.
  524.          TT_Encoding_ISO8859_1 - ISO-8859-1 (Western Europe).
  525.          TT_Encoding_ISO8859_2 - ISO-8859-2 (Eastern and Central Europe).
  526.  
  527.        TT_Transparency - Allows for rendering transparent text (the
  528.          background shines through the text). 0 value means no transparency
  529.          (this is the default), 255 is maximum transparency.
  530.  
  531.        TT_ScaleX - a floating point (IEEE single precision) horizontal scale
  532.          factor. Its absolute value will be limited to <0.01, 100> range. It
  533.          may be negative (it means horizontal mirror around starting pen
  534.          position, string will be rendered to the left).
  535.  
  536.        TT_ScaleY - a floating point (IEEE single precision) vertical scale
  537.          factor. Its absolute value will be limited to <0.01, 100> range. It
  538.          may be negative (it means vertical mirror around the baseline,
  539.          string will be rendered mostly under the baseline).
  540.  
  541.        TT_SoftStyle - controls software generated font modifications. Any of
  542.          software styles can be combined (OR-ing the values).
  543.  
  544.          TT_SoftStyle_None - clears all software styles.
  545.          TT_SoftStyle_Underlined - boolean tag controlling text underline.
  546.          TT_SoftStyle_DblUnderlined - boolean tag controlling text double
  547.            underline. Combining it with TT_Underlined gives one thick line.
  548.          TT_SoftStyle_Overstriked - boolean tag controlling text overstriked
  549.            line.
  550.          TT_SoftStyle_DblOverstriked - boolean tag controlling text
  551.            overstriked double line. Combining it with TT_Overstriked gives
  552.            one thick line.
  553.  
  554.        TT_Foreground - allows for using direct RGB value of foreground color
  555.          instead of RastPort 'A' pen. On LUT screens this tag will be
  556.          ignored. Special value TT_Foreground_UseRastPort returns foreground
  557.          color control back to the RastPort and its 'A' pen.
  558.  
  559.        TT_Background - allows for using direct RGB value of background color
  560.          (used in JAM2 drawmode only) instead of RastPort 'B' pen. On LUT
  561.          screens this tag will be ignored. Special value
  562.          TT_Background_UseRastPort returns background color control back to
  563.          the RastPort and its 'B' pen.
  564.  
  565.    INPUTS
  566.        rastport - attributes will be set for this RastPort.
  567.        taglist - the list of attributes.
  568.  
  569.    RESULT
  570.        counter - the count of recognized tags.
  571.  
  572.    NOTES
  573.  
  574.    BUGS
  575.  
  576.    SEE ALSO
  577.        TT_OpenFontA(), TT_Text(), TT_GetAttrs()
  578.  
  579. ttengine.library/TT_SetFont                       ttengine.library/TT_SetFont
  580.  
  581.    NAME
  582.        TT_SetFont -- Sets TrueType font for a RastPort. (V4)
  583.  
  584.    SYNOPSIS
  585.        TT_SetFont (rastport, font)
  586.                    A1        A0
  587.  
  588.        BOOL TT_SetFont (struct RastPort*, APTR);
  589.  
  590.    FUNCTION
  591.        Sets a font previously opened with TT_OpenFontA() for use with given
  592.        RastPort. All further calls of text rendering or metrics function for
  593.        this RastPort will use font set.
  594.  
  595.    INPUTS
  596.        rastport - The font will be set for this RastPort.
  597.        font - Pointer returned by TT_OpenFontA(). May be NULL, function
  598.            returns immediately in the case.
  599.  
  600.    RESULT
  601.        TRUE if success, false otherwise.
  602.  
  603.    EXAMPLE
  604.        /* use two fonts to render in one RastPort */
  605.  
  606.        APTR times, arial;
  607.  
  608.        times = TT_OpenFont(
  609.           TT_FamilyTable, (ULONG){"Times", "serif", "default", NULL},
  610.           TT_FontSize, 26,
  611.        TAG_END);
  612.  
  613.        arial = TT_OpenFont(
  614.           TT_FamilyTable, (ULONG){"Arial", "sans-serif", "default", NULL},
  615.           TT_FontSize, 22,
  616.           TT_FontWeight, TT_FontWeight_Bold,
  617.        TAG_END);
  618.  
  619.        if (times && arial)
  620.          {
  621.            SetAPen(win->RPort, 1);
  622.            SetDrMd(win->RPort, JAM1);
  623.            Move(win->RPort, 100, 100);
  624.            TT_SetAttrs(win->RPort, TT_Window, win, TAG_END);
  625.  
  626.            if (TT_SetFont(win->RPort, times))
  627.              TT_Text(win->RPort, "Times 26 points", 15);
  628.            if (TT_SetFont(win->RPort, arial))
  629.              TT_Text(win->RPort, "Arial 22 points", 15);
  630.          }
  631.        if (arial) TT_CloseFont(arial);
  632.        if (times) TT_CloseFont(times);
  633.  
  634.    NOTES
  635.      Function can fail returning FALSE if:
  636.      1. RastPort pointer is NULL.
  637.      2. Font pointer is NULL.
  638.      3. Font pointer is not found on opened fonts list (it means the pointer
  639.         was not obtained as a result of TT_OpenFontA() call).
  640.      4. Memory allocation during environment creation fails.
  641.  
  642.    BUGS
  643.  
  644.    SEE ALSO
  645.        TT_OpenFontA(), TT_SetAttrsA(), TT_CloseFont()
  646.  
  647. ttengine.library/TT_Text                             ttengine.library/TT_Text
  648.  
  649.    NAME
  650.        TT_Text -- Renders string into RastPort. (V4)
  651.  
  652.    SYNOPSIS
  653.        TT_Text (rastport, string, count)
  654.                 A1        A0      D0
  655.  
  656.        VOID TT_Text (struct RastPort*, APTR, ULONG);
  657.  
  658.    FUNCTION
  659.        Renders the string using current ttengine.library settings, and
  660.        current RastPort settings (pen, drawmode). String is rendered at
  661.        current RastPort (x, y) position, where 'y' means position of font
  662.        baseline. String is converted to Unicode according to
  663.        current (set by TT_SetAttrs()) encoding table.
  664.  
  665.    INPUTS
  666.        rastport - Target RastPort for rendering.
  667.        string - String to render to (need not to be NULL terminated).
  668.        count - How many characters to render (note that NULL code will
  669.            be rendered as well).
  670.  
  671.    RESULT
  672.        none
  673.  
  674.    EXAMPLE
  675.        /* write a text with pen 1 and transp. background at (100, 100) */
  676.        /* rendering is done to a system window                         */
  677.  
  678.        SetAPen(win->RPort, 1);
  679.        SetDrMd(win->RPort, JAM1);
  680.        Move(win->RPort, 100, 100);
  681.        TT_SetAttrs(win->RPort, TT_Window, win, TAG_END);
  682.        TT_Text(win->RPort, "some text", 9);
  683.  
  684.    NOTES
  685.  
  686.    BUGS
  687.  
  688.    SEE ALSO
  689.        TT_OpenFontA(), TT_SetAttrsA()
  690.  
  691. ttengine.library/TT_TextExtent                 ttengine.library/TT_TextExtent
  692.  
  693.    NAME
  694.        TT_TextExtent -- Determine raster extent of text data. (V4)
  695.  
  696.    SYNOPSIS
  697.        TT_TextExtent (rastport, text, count, extent)
  698.                       A1        A0    D0:16  A2
  699.  
  700.        VOID TT_TextExtent (struct RastPort*, APTR, WORD,
  701.            struct TextExtent*);
  702.  
  703.    FUNCTION
  704.        Computes dimensions and coordinates of smallest rectangle containing
  705.        on the whole given text rendered with current settings. TextExtent
  706.        structure fields have following meaning:
  707.  
  708.        te_Width - Horizontal advance of RastPort pen position. The same as
  709.            TT_TextLength() call result.
  710.        te_Height - Just current font height.
  711.        te_Extent.MinX - The horizontal distance from text start point to the
  712.            leftmost pixel rendered. May be negative, it means that some
  713.            pixels will be plotted before the start point.
  714.        te_Extent.MaxX - The horizontal distance from text start point to the
  715.            rightmost pixel rendered.
  716.        te_Extent.MinY - The vertical distance from text start point to the
  717.            topmost pixel rendered. Always negative, do not neccesarily equal
  718.            to -TTFA_Ascender.
  719.        te_Extent.MaxY - The vertical distance from text start point to the
  720.            lowermost pixel rendered. Typically positive if anything is to be
  721.            drawn below the baseline.
  722.  
  723.    INPUTS
  724.        rastport - this rastport settings (font, size, style etc.) will be
  725.            used for calculations.
  726.        text - a string (not neccesarily NULL-terminated) to compute the
  727.            rectangle for.
  728.        count - length of the string in characters.
  729.        extent - pointer to TextExtent structure - it will be filled with
  730.            data.
  731.  
  732.    RESULT
  733.        No retrurn value. TextExtent structure is filled with data.
  734.  
  735.    NOTES
  736.        This function is almost identical to graphics.library/TextExtent().
  737.        It even receives parameters in the same registers.
  738.  
  739.        Do not assume neither horizontal extents sum up to te_Width, nor
  740.        vertical ones sum up to font height.
  741.  
  742.    BUGS
  743.  
  744.    SEE ALSO
  745.        TT_OpenFontA(), graphics.library/TextExtent()
  746.  
  747. ttengine.library/TT_TextFit                       ttengine.library/TT_TextFit
  748.  
  749.    NAME
  750.        TT_TextFit -- Count characters that will fit in a given extent. (V4)
  751.  
  752.    SYNOPSIS
  753.        characters = TT_TextFit (rastport, string, count, extent,
  754.                                 A1        A0      D0:16  A2
  755.            constr_extent, direction, width, height)
  756.            A3             D1         D2     D3
  757.  
  758.        ULONG TT_TextFit (struct RastPort*, APTR, UWORD, struct TextExtent*,
  759.            struct TextExtent*, WORD, UWORD, UWORD);
  760.  
  761.    FUNCTION
  762.        Computes how many characters of given NULL-terminated string rendered
  763.        with current settings will fit into given extent. Also calculates an
  764.        extent for this fitting part of the string. Function can fit from the
  765.        beginning of the string to the right, or from the end of the string
  766.        to the left. If 'constr_extent' is non NULL, string is fitted only
  767.        against it, constraining 'width' and 'height' are ignored.
  768.  
  769.    INPUTS
  770.        rastport - calculations will be performed using this rastport
  771.            settings (font, size, styles etc.).
  772.        string - A string (not neccesarily NULL-terminated) to fit.
  773.        count - string lenght in characters.
  774.        extent - Pointer to TextExtent structure - it will be filled with
  775.            dimensions of fitted part of the string. May be filled with all
  776.            zeros if no fit is possible at all (e.g. height is to small).
  777.        constr_extent - Pointer to already filled TextExtent structure. Part
  778.            of the string will fit into this extent. It is not modified by
  779.            function. May be NULL, 'width' and 'height' will be used as
  780.            constraints.
  781.        direction - When equal to 1 string will be fitted starting from it's
  782.            beginning to the rigth. When equal to -1, string will be fitted
  783.            starting from it's end to the left.
  784.        width - If 'constr_extent' is NULL, the string width will be compared
  785.            with this parameter. Ignored otherwise.
  786.        height - If 'constr_extent' is NULL, the string height will be
  787.            compared with this parameter. Ignored otherwise.
  788.  
  789.    RESULT
  790.        characters - the length of fitting string part. May be zero if no fit
  791.            found.
  792.  
  793.    NOTES
  794.        This function is almost identical to graphics.library/TextFit().
  795.        It even receives parameters in the same registers.
  796.  
  797.        Do not assume neither horizontal extents sum up to te_Width, nor
  798.        vertical ones sum up to font height (in returned extent).
  799.  
  800.    BUGS
  801.  
  802.    SEE ALSO
  803.        TT_OpenFontA(), graphics.library/TextFit()
  804.  
  805. ttengine.library/TT_TextLength                 ttengine.library/TT_TextLength
  806.  
  807.    NAME
  808.        TT_TextLength -- Gets string length in pixels (V4).
  809.  
  810.    SYNOPSIS
  811.        length = TT_TextLength(rastport, string, count)
  812.                               A1        A0      D0
  813.  
  814.        ULONG TT_TextLength (struct RastPort*, APTR, ULONG);
  815.  
  816.    FUNCTION
  817.        Calculates the pixel width of given string written with current font.
  818.        Takes kerning into account. String will be mapped to Unicode using
  819.        current encoding.
  820.  
  821.    INPUTS
  822.        rastport - render engine and font settings for this RastPort will be
  823.            used for calculations.
  824.        string - the length of this string will be calculated.
  825.        count - the string lenght in characters.
  826.  
  827.    RESULT
  828.        length - the length of the string in pixels.
  829.  
  830.    NOTES
  831.  
  832.    BUGS
  833.  
  834.    SEE ALSO
  835.        TT_Text(), TT_OpenFontA()
  836.  
  837.